﻿<!DOCTYPE html>
<html>
  <head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9"/>
	<title>jTopo Demo 性能测试</title>
	<meta name="description" content="jTopo免费的基于HTML5 Canvas的网络拓扑、关系图形库 性能测试">
	<meta name="keyword" content="jTopo 网络 拓扑 图形库 HTML5 Canvas 免费 关系图形库 javascript topology 性能测试">	
	<link rel="stylesheet" type="text/css" href="../css/base.css">
	<link href="../css/jquery.snippet.min.css" rel="stylesheet">
	
	<script src="../js/jquery.js"></script>
	<script src="../js/site.js"></script>
	<script src="../js/demo.js"></script>
	
	<script type="text/javascript" src="js/snippet/jquery.snippet.min.js"></script>
	
	<script type="text/javascript" src="js/jtopo-min.js"></script>
	<script type="text/javascript" src="js/toolbar.js"></script>
	
	<script id='code'>
		$(document).ready(function(){								
			var canvas = document.getElementById('canvas');
			var stage = new JTopo.Stage(canvas);
			//显示工具栏
			showJTopoToobar(stage);

			var scene = new JTopo.Scene(stage);	
			stage.wheelZoom = 0.85; // 鼠标缩放
			scene.background = './img/bg.jpg';
	
			// 节点数量( 10万 5万条连线）
			var nodeCount = 10000; 
			
			// 生成随机坐标
			function randomCoor(range){
				return Math.random()* range - Math.random() * range;
			}
			
			function createNode(x, y, text){
				var node = new JTopo.CircleNode();
				node.radius = 10;
				node.shadow = false;
				node.tip = text;
				node.mouseover(function(){
					this.text = this.tip;
				});
				node.mouseout(function(){
					this.text = "";
				});
				node.setSize(20,20);
				node.setLocation(x, y);	
				node.fillColor = JTopo.util.randomColor();
				scene.add(node);
				return node;
			}
			
			var beginTime = (new Date()).getTime();
			// 每次循环创建两个节点、一条连线
			for(var i= 0; i<nodeCount/2; i++){
				var x = randomCoor(3000);
				var y = randomCoor(3000);				
				var nodeFrom = createNode(x, y, 'From_' + i);
				
				var x2 = x + randomCoor(1000);
				var y2 = y + randomCoor(1000);
				var nodeTo =  createNode(x2, y2, 'To_' + i);
				
				var link = new JTopo.Link(nodeFrom, nodeTo);
				link.shadow = false;
				link.lineWidth = 1;
				scene.add(link);
			};

			var usedTime = ((new Date()).getTime() - beginTime) / 1000;
			$('#msg').html('随机生成1万个节点、5000条连线, 用时：' + usedTime + ' 秒.');
		});
	</script>	
  </head>

  <body>

	<center>
	<div class="wrap_div">
		<div class="head_nav">
			<h2 class="logo"><a href="index.html" title="jTopo">jTopo</a></h2>
		</div>		
		<div class="head_nav_second">			
			<ul class="menu" id="nav_menu">
			
			</ul>
		</div>		
		<div class="content">			
		  <div class="left">
			<ul id="menu">
			
			</ul>
		  </div>
		  <div class="right">
			<h2 id="msg">随机生成1万个节点、5000条连线 (创建数据较多, 期间请耐心等候)</h2>
				<div id="content">					<canvas width="850" height="550" id="canvas"></canvas>	
					
				</div>
		  </div>
		  <div class="clear"></div>
		</div>
	</div>
	</center>
	<div class="footer">
		&nbsp;
	</div>
  <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1000418207'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "v1.cnzz.com/z_stat.php%3Fid%3D1000418207%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));</script>
	</body>
</html>